package com.mida.bms.report.api;

import com.mida.bms.report.vo.*;
import com.mida.tool.common.result.ActionResult;
import com.mida.tool.common.result.ListResult;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.DependsOn;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * <h1>报告书写对外服务</h1>
 * <p>
 *
 * </p>
 *
 * @author jian.li on 2021/6/16 10:36
 */
@DependsOn("loadFromDatabasePropertyConfig")
@FeignClient(name = "docReportApi", url = "bms.report.feign.url")
public interface DocReportApi {

    /**
     * 暂存报告(只存mongodb)
     *
     * @param request 暂存报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/saveTeporarily", consumes = {"application/json"})
    @ResponseBody
    ListResult<ReportResult> saveTemporarily(@RequestBody DocReportPreservationRequest request);

    /**
     * 签署报告
     * <p>
     * 共保存三份:
     * 1.json(存在mongodb中)
     * 2.pdf
     * 3.结构化报告
     *
     * @param request 保存报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/saveDocReport", consumes = {"application/json"})
    @ResponseBody
    ListResult<String> saveDocReport(@RequestBody DocReportPreservationRequest request);

    /**
     * 报告(初写完成待审核)编辑/撤回
     *
     * @param stReportSoid 报告存储信息标识
     * @return
     */
    @PostMapping(value = "/docReport/editDocReport", consumes = {"application/json"})
    @ResponseBody
    ActionResult editDocReport(@RequestParam("stReportSoid") Long stReportSoid, @RequestParam("employeeSoid") Long employeeSoid);

    /**
     * 报告回显
     *
     * @param request 报告回显请求参数
     * @return
     */
    @PostMapping(value = "/docReport/getDocReport", consumes = {"application/json"})
    @ResponseBody
    ListResult<ReportResult> getDocReport(@RequestBody DocReportInitializationRequest request);

    /**
     * 业务态保存报告模板
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/docReport/saveTemplate", consumes = {"application/json"})
    @ResponseBody
    ActionResult saveTemplate(@RequestBody DocReportPreservationRequest request);

    /**
     * 接收报告，将报告改为已审核，保存报告
     *
     * @param reportRequest
     * @return
     */
    @PostMapping(value = "/docReport/modifyReportStatus", consumes = {"application/json"})
    @ResponseBody
    ActionResult modifyReportStatus(@RequestBody DocReportPreservationRequest reportRequest);

    /**
     * 退回报告，将报告改为审核已退回
     *
     * @param stReportSoid
     * @return
     */
    @GetMapping("/docReport/modifyStatus")
    @ResponseBody
    ActionResult modifyStatus(@RequestParam("stReportSoid") String stReportSoid, @RequestParam("employeeSoid") Long employeeSoid);

    /**
     * 8.报告通过审核，撤回报告
     *
     * @param
     * @return
     */
    @GetMapping(value = "/docReport/withdrawStatus", consumes = {"application/json"})
    @ResponseBody
    ActionResult withdrawStatus(@RequestParam("stReportSoid") String stReportSoid, @RequestParam("employeeSoid") Long employeeSoid);

    /**
     * 获取报告pdf
     *
     * @param request
     * @return
     */
    @PostMapping("/docReport/getReportPdf")
    @ResponseBody
    Response getReportPdf(@RequestBody ReportSearchRequest request);

    /**
     * 保存结构化报告
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/docReport/saveStructuredReport", consumes = {"application/json"})
    @ResponseBody
    ActionResult saveStructuredReport(@RequestBody StructuredReportRequest request);

    /**
     * 根据登记号，检查号签署报告
     */
    @PostMapping(value = "/docReport/saveDocReportByRegistrationAndExam", consumes = {"application/json"})
    @ResponseBody
    ListResult<String> saveDocReportByRegistrationAndExam(@RequestBody DocReportPreservationRequest request);

    /**
     * 根据申请单标识，登记标识，检查号 报告回显
     *
     * @param request 报告回显请求参数
     * @return
     */
    @PostMapping(value = "/docReport/getDocReportByTypes", consumes = {"application/json"})
    @ResponseBody
    ListResult<ReportResult> getDocReportByTypes(@RequestBody DocReportInitializationRequest request);

    /**
     * 根据申请单，登记单，检查单号初始化模板报告
     *
     * @param docReportInitializationRequest 初始化模板报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/initializeDocReportTypes", consumes = {"application/json"})
    @ResponseBody
    ListResult<ReportInitializationResult> initializeDocReportTypes(@RequestBody DocReportInitializationRequest docReportInitializationRequest);

    /**
     * 根据申请单号，登记单号，检查号暂存报告
     *
     * @param request 暂存报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/saveTemporarilyTypes", consumes = {"application/json"})
    @ResponseBody
    ListResult<ReportResult> saveTemporarilyTypes(@RequestBody DocReportPreservationRequest request);


    /**
     * 根据StReportSoid从docReportRequisitionRelation表中查询全部列表
     *
     * @return
     */
    @PostMapping(value = "/docReport/selectByStReportSoid", consumes = {"application/json"})
    @ResponseBody
    List<DocReportRequisitionRelationVo> selectByStReportSoid(@RequestParam("stReportSoid") Long stReportSoid);

    /**
     * 17.获取报告pdfurl
     *
     * @param request
     * @return
     */
    @GetMapping("/docReport/getReportPdfUrl")
    @ResponseBody
    ListResult<String> getReportPdfUrl(@RequestBody ReportSearchRequest request);

    /**
     * 获取图片
     *
     * @param
     * @return
     */
    @GetMapping("/docReport/getReportPdfImage")
    @ResponseBody
    List<String> getReportPdfImage();

    /**
     * 获取报告pdf历史(提供给上游申请单使用)
     *
     * @param requestSoidList
     * @return
     */
    @PostMapping("/docReport/getReportPdfHistory")
    @ResponseBody
    ListResult<Map<String, List<String>>> getReportPdfHistory(@RequestBody List<Long> requestSoidList);

    /**
     * 18.查询待书写的报告和已完成报告的数量
     *
     * @return
     */
    @PostMapping(value = "/docReport/queryReportsNumbers", consumes = {"application/json"})
    @ResponseBody
    ListResult<StatusSum> queryReportsNumbers(@RequestBody QueryReportsNumberDto queryReportsNumberDto);

    /**
     * 发布报告(支持批量)
     *
     * @param reportPublishRequest 发布报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/publishReport", consumes = {"application/json"})
    @ResponseBody
    ActionResult publishReport(@RequestBody ReportPublishRequest reportPublishRequest);

    /**
     * 召回报告
     *
     * @param reportRecallRequest 召回报告请求参数
     * @return
     */
    @PostMapping(value = "/docReport/recallReport", consumes = {"application/json"})
    @ResponseBody
    ActionResult recallReport(@RequestBody ReportRecallRequest reportRecallRequest);


    /**
     * 暂缓报告
     *
     * @param requestSoid          申请单id
     * @param personSoid           检查id
     * @param registrationFormSoid 登记id
     * @return
     */
    @PostMapping(value = "/docReport/postponeReport", consumes = {"application/json"})
    @ResponseBody
    ActionResult postponeReport(@RequestParam("requestSoid") String requestSoid, @RequestParam("personSoid") String personSoid,
                                @RequestParam("registrationFormSoid") String registrationFormSoid);

    /**
     * 修改危急值主表状态为已发送
     *
     * @param docReportCritivalValueSoid
     * @return
     */
    @GetMapping(value = "/docReport/sentCriticalValue", consumes = {"application/json"})
    @ResponseBody
    ActionResult sentCriticalValue(@RequestParam("docReportCritivalValueSoid") Long docReportCritivalValueSoid);

    /**
     * 19.根据报告soid查询报告
     *
     * @param stReportSoid 报告soid
     * @return
     */
    @PostMapping(value = "/docReport/getDocReportByStReportSoid")
    @ResponseBody
    ListResult<ReportResult> getDocReportByStReportSoid(@RequestParam("stReportSoid") Long stReportSoid);

    /**
     * 保存危急值并转发到代理(网关)
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/docReport/saveCritivalValue")
    @ResponseBody
    ListResult<Long> saveCritivalValue(@RequestBody CriticalValueRequest request);
}
